package com.djmw.mouse.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.Min;

import org.hibernate.validator.constraints.NotBlank;

//JPA标识
@Entity
@Table(name = "t_industry")
public class Industry extends IdEntity {

    private String name;
    private Industry parent;
    private int order;

    public Industry() {

    }

    // JSR303 BeanValidator的校验规则
    @NotBlank
    @Column(name = "c_name")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    // JPA 基于USER_ID列的多对一关系定义
    @ManyToOne(optional = true)
    @JoinColumn(name = "c_parent_id", referencedColumnName = "c_id")
    public Industry getParent() {
        return parent;
    }

    public void setParent(Industry parent) {
        this.parent = parent;
    }

    // JSR303 BeanValidator的校验规则
    @Min(100)
    @Column(name = "c_order")
    public int getOrder() {
        return order;
    }

    public void setOrder(int order) {
        this.order = order;
    }
}
